package cn.edu.nju.software.zp13.client.assignment3.studentListXml;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import cn.edu.nju.software.zp13.client.assignment3.seeder.StudentGenerator;
import cn.edu.nju.software.zp13.client.assignment3.xmlNodeEntity.Student;


public class StudentList2Xml extends StudentListXml {
	@Override
	protected void processDom(Document dom) {
		NodeList list=dom.getElementsByTagName("students");
		if(list.getLength()>0){
			Node root=list.item(0);
			Student[] students = StudentGenerator.run();
			for (Student s : students) {
				Node studentNode = s.toXmlNode(dom);
				root.appendChild(studentNode);
			}
		}else{
			System.err.println("can't find element <students></students>");
			System.exit(0);
		}
	}
}
